<?php

class Core_Table_Permission_Role extends Kd_Data_Table {

    public function __construct() {
        parent::__construct();
    }

    public function insertIdPath($id, $idPath, $transaction = NULL) {
        Kd_Data_Factory::getUpdateDcl()
                ->into($this->getName())
                ->value('id_path', ':idPath:s')
                ->where()->eq('id', ':id:i')->endSelf()
                ->addParameter(array('id' => $id, 'idPath' => $idPath))
                ->setDbDriver($this->getDbDriver($transaction))
                ->execute();
    }

    public function updateIdPath($oldIdPath, $newIdPath, $transaction = NULL) {
        Kd_Data_Factory::getUpdateDcl()
                ->into($this->getName())
                ->value('id_path', Kd_Data_Dcl_Fn::stringConcat("'$newIdPath'", Kd_Data_Dcl_Fn::stringSub('id_path', strlen($oldIdPath) + 1)))
                ->where()->like('id_path', "'$oldIdPath%'")
                ->closest()
                ->setDbDriver($this->getDbDriver($transaction))
                ->execute();
    }
}